<%@ page language="java" contentType="text/html; charset=ISO-8859-1" pageEncoding="ISO-8859-1"%>
<%@ page import="com.c0nflict.server.*" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<%@ include file="admin_header.jspf" %>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>c0nflict: Table Manager - Sessions</title>
</head>
<body>

<center><h3 style="color: #ccc;"><b><%= tm.WATCHDOG.toString() %></b></h3></center>

<center><font size="5" color="white" face="verdana"><b>Sessions</b></font></center>

<table align="center" style="width: 15%;" cellpadding="4" cellspacing="0">
<thead>
<tr>
	<th width="60px">sessionUsers</th>
	<th width="60px">userSessions</th>
</tr>
</thead>
<tbody style="height: 20px;">
<tr>
	<td><%= tm.userSessions.keySet().size() %></td>
	<td><%= tm.sessionUsers.keySet().size() %></td>
</tr>
</tbody>
</table>
<br/>
<%
	int bots = 0;
	int players = 0;
	int watchers = 0;
	int blocked = 0;
	for (Player p : tm.userSessions.keySet()) {
		if (p.isBlocked())
			blocked++;
		if (p.isNobody())
			watchers++;
		if (p.isPlayer() && !p.isAutomaton())
			players++;
		if (p.isAutomaton())
			bots++;
	}
%>
<table align="center" style="width: 30%;" cellpadding="4" cellspacing="0">
<thead>
<tr>
	<th width="60px">Watchers</th>
	<th width="60px">Players</th>
	<th width="60px">Blocked</th>
	<th width="60px">Bots</th>
</tr>
</thead>
<tbody style="height: 20px;">
<tr>
	<td><%= watchers %></td>
	<td><%= players %></td>
	<td><%= blocked %></td>
	<td><%= bots %></td>
</tr>
</tbody>
</table>
<br/>
<div class="sessionsContainer">
<table class="sortable" cellpadding="4" cellspacing="0">
<thead>
<tr>
	<th width="60px">Db Id</th>
	<th width="120px">Session Id</th>
	<th width="200px">Name</th>
	<th width="200px">Referer</th>
</tr>
</thead>
<tbody>
<% for (Player p : tm.userSessions.keySet()) { %>
<tr <% if (p.isPlayer()) { %> bgcolor="#222" <% } 
  String ref = null;
  try {
  if (p.getHttpSession()!=null) ref=(String)p.getHttpSession().getAttribute("DQOR");
  } catch (Exception e) {}
%> >
	<td><%= p.getDbId() %></td>
	<td><%= p.getSession().getId() %></td>
	<td><%= p.getName() %></td>
	<td><%= ref %></td>

</tr>
	<% } %>
</tbody>
</table>
</div>
<%@ include file="admin_footer.jspf" %>
</body>
</html>
